import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_baidu_mapapi_map/flutter_baidu_mapapi_map.dart';
import 'package:flutter_bmfmap_example/tool/tool.dart';
import 'package:flutter_baidu_mapapi_base/flutter_baidu_mapapi_base.dart'
    show BMFCoordinate, BMFEdgeInsets, BMFMapSDK, BMFPoint, BMF_COORD_TYPE;

class FamilyPage extends StatefulWidget {
  FamilyPage({Key key, this.title, this.personinfo}) : super(key: key);
  final String title;
  var personinfo;
  @override
  _FamilyPageState createState() => _FamilyPageState();
}

class _FamilyPageState extends State<FamilyPage> {

  BMFMapOptions mapOptions = BMFMapOptions(
      compassEnabled: true,
      compassPosition: BMFPoint(50.0, 800.0),
      mapZoomControlPosition: BMFPoint(50.0, 1500.0),
      center: BMFCoordinate(25.0572, 102.74129),
      zoomLevel: 18,
      mapPadding: BMFEdgeInsets(left: 0, top: 0, right: 0, bottom: 0));

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        elevation: 0,
        iconTheme: IconThemeData(color: Colors.black54),
        backgroundColor: Colors.transparent,
      ),
      body: Container(
        // color: Color.fromRGBO(255,230,113, 1),
        child: ListView(
          // crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            //头像行
            _profile(),
            //文字图标行
            Padding(
              padding: const EdgeInsets.only(left: 32, right: 32),
              child: Row(
                children: [
                  Text(
                    '位置',
                    style: TextStyle(
                        color: Color.fromRGBO(81, 75, 111, 1),
                        fontSize: 18,
                        fontWeight: FontWeight.bold),
                  ),
                  Spacer(),
                  Icon(
                    Icons.room,
                    color: Color.fromRGBO(81, 75, 111, 1),
                    size: 30,
                  )
                ],
              ),
            ),
            //地图行
            Container(
              height: 240,
              // width: 300,
              margin: EdgeInsets.fromLTRB(32, 16, 32, 16),
              decoration: new BoxDecoration(
                color: Color.fromRGBO(114, 92, 201, 1),
                //设置四周圆角 角度
                borderRadius: BorderRadius.all(Radius.circular(20.0)),
              ),
              child: ClipRRect(
                borderRadius: BorderRadius.circular(20),
                child: BMFMapWidget(
                  
                  onBMFMapCreated: (controller) {},
                  mapOptions: mapOptions,
                ),
              ),
            ),
            //文字行
            Padding(
              padding: const EdgeInsets.only(
                  left: 32, top: 16, bottom: 8, right: 32),
              child: Text(
                '健康数据',
                style: TextStyle(
                    color: Color.fromRGBO(81, 75, 111, 1),
                    fontSize: 18,
                    fontWeight: FontWeight.bold),
              ),
            ),
            //心律行
            _heartRate('76'),
            //体温步数行
            Padding(
              padding: const EdgeInsets.only(left: 32, right: 32, top: 8),
              child: Row(
                children: [
                  //步数
                  _stepts(2354),
                  SizedBox(
                    width: 8,
                  ),
                  _bodyTemperature(12),
                  // Spacer(),
                  //体温
                  // _bodyTemperature(36.4)
                ],
              ),
            ),
          ],
        ),
      ),
    );
  }

//步数
  _stepts(steps) {
    return Expanded(
      child: Container(
        child: Column(
          children: [
            Row(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Image.asset('assets/images/common/运动.png',
                    width: 50, height: 50),
                Padding(
                  padding: const EdgeInsets.only(top: 15.0),
                  child: Text(
                    '步数',
                    style: TextStyle(
                        color: Color.fromRGBO(180, 175, 205, 1), fontSize: 16),
                  ),
                ),
              ],
            ),
            Text(
              '$steps',
              style: TextStyle(
                  color: Color.fromRGBO(81, 75, 111, 1),
                  fontSize: 22,
                  fontWeight: FontWeight.bold),
            )
          ],
        ),
        // margin: EdgeInsets.fromLTRB(10, 0, 10, 0),
        height: 100,
        // width: 140,
        decoration: new BoxDecoration(
          color: Color.fromRGBO(245, 230, 255, 1),
          //设置四周圆角 角度
          borderRadius: BorderRadius.all(Radius.circular(10.0)),
        ),
      ),
    );
  }

  _bodyTemperature(steps) {
    return Expanded(
      child: Container(
        child: Column(
          children: [
            Row(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Image.asset('assets/images/common/温度.png',
                    width: 50, height: 50),
                Padding(
                  padding: const EdgeInsets.only(top: 15.0),
                  child: Text(
                    '体温',
                    style: TextStyle(
                        color: Color.fromRGBO(180, 175, 205, 1), fontSize: 16),
                  ),
                ),
              ],
            ),
            Text(
              '$steps',
              style: TextStyle(
                  color: Color.fromRGBO(81, 75, 111, 1),
                  fontSize: 22,
                  fontWeight: FontWeight.bold),
            )
          ],
        ),
        // margin: EdgeInsets.fromLTRB(10, 0, 10, 0),
        height: 100,
        // width: 140,
        decoration: new BoxDecoration(
          color: Color.fromRGBO(245, 230, 255, 1),
          //设置四周圆角 角度
          borderRadius: BorderRadius.all(Radius.circular(10.0)),
        ),
      ),
    );
  }

//体温

//心率
  _heartRate(heartrate) {
    return Padding(
        padding: const EdgeInsets.only(left: 32, right: 32),
        child: Container(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Padding(
                padding: const EdgeInsets.all(16.0),
                child: Row(
                  children: [
                    Column(
                      children: [
                        Image.asset('assets/images/common/心.png',
                            width: 36, height: 36),
                        Text(
                          '$heartrate bmp',
                          style: TextStyle(
                              color: Color.fromRGBO(81, 75, 111, 1),
                              fontSize: 16,
                              fontWeight: FontWeight.bold),
                        )
                      ],
                    ),
                    Expanded(
                      child: Image.asset(
                        'assets/images/common/心率.png',
                        height: 80,
                        width: 200,
                      ),
                    ),
                  ],
                ),
              ),
            ],
          ),
          height: 140,
          // width: 300,
          decoration: new BoxDecoration(
            color: Color.fromRGBO(245, 230, 255, 1),
            //设置四周圆角 角度
            borderRadius: BorderRadius.all(Radius.circular(10.0)),
          ),
        ));
  }

//头像行
  _profile() {
    return Padding(
        padding: const EdgeInsets.only(left: 30, bottom: 20, top: 20),
        child: Row(
          children: [
            Container(
              child: Hero(
                  tag: widget.personinfo['logoId'],
                  child: Image.asset(
                    Tool.getportrait(widget.personinfo['logoId']),
                    width: 80,
                  ),
                ),
            ),
            // Image.asset('$profile'),

            Padding(
              padding: const EdgeInsets.only(left: 10),
              child: Container(
                child: Padding(
                  padding: const EdgeInsets.only(left: 5),
                  child: Text(
                    widget.personinfo['personName'],
                    style: TextStyle(
                        color: Color.fromRGBO(81, 75, 111, 1),
                        fontSize: 22,
                        fontWeight: FontWeight.bold),
                  ),
                ),
              ),
            )
          ],
        ));
  }
}
